<?php
	/* 
    Plugin Name: Wtfaq formulier plugin
    Plugin URI: http://www.wtfaq.nl 
    Description: Plugin om een nieuwe FAQ in te voeren 
    Author: Abu Saebu
    Version: 1.0 
    Author URI: http://www.voiceable.nl
    */
session_start();
if (isset($_GET['logout']))
		unset($_SESSION['wtfaq']);
		
add_shortcode('WTFAQFORM', 'wtfaq_form');

function wtfaq_form($atts) {
wp_enqueue_script('wtfaq','http://maps.googleapis.com/maps/api/js?key=AIzaSyBEDI_-eupFFw88kcFm051XHkiBPOIXlzg&sensor=true');
//<script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyBEDI_-eupFFw88kcFm051XHkiBPOIXlzg&sensor=true"></script>

$email = isset($_SESSION['wtfaq']['email']) ? $_SESSION['wtfaq']['email'] : "";
$plugindirurl = plugin_dir_url(__FILE__);
print <<<JS
<div id="single-post-map" style="width: 100%; height:320px;  "></div>
<script src="{$plugindirurl}wtfaq.js"></script>   
<script src="{$plugindirurl}wtfaqform.js"></script>
JS;
print <<<HTML
<style>
form{margin:0;padding:0;}
fieldset{margin:1em 0;border:none;border-top:1px solid #ccc;}
legend{margin:1em 0;padding:0 .5em;color:#036;background:transparent;font-size:1.3em;font-weight:bold;}
label{float:left;width:200px;padding:0 1em;text-align:right;}
fieldset div{margin-bottom:.5em;padding:0;display:block;}
fieldset div input,fieldset div textarea{width:250px;border-top:1px solid #555;border-left:1px solid #555;border-bottom:1px solid #ccc;border-right:1px solid #ccc;padding:1px;color:#333;}
fieldset div select{padding:1px;}div.fm-multi div{margin:5px 0;}
div.fm-multi input{width:1em;}div.fm-multi label{display:block;width:200px;padding-left:5em;text-align:left;}
#fm-submit{clear:both;padding-top:1em;text-align:center;}
#fm-submit input{border:1px solid #333;padding:2px 1em;background:#555;color:#fff;font-size:100%;}
input:focus,textarea:focus{background:#efefef;color:#000;}
div input[type=radio] {width: 2em;}
fieldset div.fm-req{font-weight:bold;}fieldset div.fm-req label:before{content:"* ";}
#loginblock {display: block; text-align:right; width: 100%; font-weight:bold;}
</style>
<div id='formfaq-div'>
HTML;
if (!isset($_SESSION['wtfaq']['UID'])) 
print <<<NOTLOG
	<span id='loginblock'>Niet ingelogd</span>
	<form name='formfaq' id='formfaq'>
	<fieldset id='fs-login'>
	<legend>Login/Registreer</legend>
	<div>
		<label>Emailadres *</label>
		<input type='text' name='email' placeholder='Vul een geldig emailadres in' required>
	</div>
	<div>
		<label>Wachtwoord *</label>
		<input type='text' name='token' placeholder='Voer je wachtwoord in' required>
	</div>
	</fieldset>
NOTLOG;
else {
print  <<<LOG
<span id='loginblock'>$email&nbsp;<a href='?logout'>log uit</a></span>
<form name='formfaq' id='formfaq'>

LOG;
}
print <<<MHTML
	<input name='geocoords' value='' type='hidden'>
	<legend>Meta gegevens</legend>
	<fieldset >
	<div id='div-title'>
		<label>Titel FAQ *</label>
		<input type='text' name='title' placeholder='Unieke naam voor FAQ' required>
	</div>
	<div id='div-location'>
		<label>Omschrijving locatie</label>
		<input type='text' name='location' placeholder='Naam locatie of evenement' >
	</div>
	</fieldset>
	<div>
	<label>&nbsp;</label>
	<input type='button' name='button-wtfaq' value='Verstuur' >
	</div>
	</form>
</div>
<div id=question-div style='display:none;'>
<form name='question' id='frmquestion' >
	<input type='hidden' name='wtfaqId' value='0'>
	<input type='hidden' name='questionId' value=''>
	<legend>FAQ</legend>
	<fieldset >
	<div id='divvraag'>
		<label>Vraag</label>
		<input type='text' name='question' placeholder='Wat is de veelgestelde vraag' required>
	</div>
	<div>
		<label>Antwoord</label>
		<textarea name=answer rows=10 cols=60 required placeholder='Wat is het antwoord ?'></textarea>
	</div>
	<div>
	<label>&nbsp;</label>
	<input type='button' name='button-question-next' value='Verstuur' >
	<input type='button' name='button-question-end' value='Stop sessie' >
	</div>
</form>
</div>			   
MHTML;
}
?>